import request from '@/utils/request'

// 查询调研问卷列表
export function listQuestionnaire(query) {
  return request({
    url: '/research/questionnaire/list',
    method: 'get',
    params: query
  })
}

// 查询调研问卷详细
export function getQuestionnaire(questionnaireId) {
  return request({
    url: '/research/questionnaire/' + questionnaireId,
    method: 'get'
  })
}

// 新增调研问卷
export function addQuestionnaire(data) {
  return request({
    url: '/research/questionnaire',
    method: 'post',
    data: data
  })
}

// 修改调研问卷
export function updateQuestionnaire(data) {
  return request({
    url: '/research/questionnaire',
    method: 'put',
    data: data
  })
}

// 调研问卷状态修改
export function changeQuestionnaireStatus(questionnaireId, status) {
  const data = {
    questionnaireId,
    status
  }
  return request({
    url: '/research/questionnaire/status',
    method: 'post',
    data: data
  })
}

// 删除调研问卷
export function delQuestionnaire(questionnaireId) {
  return request({
    url: '/research/questionnaire/' + questionnaireId,
    method: 'delete'
  })
}

// 导出调研问卷
export function exportQuestionnaire(query) {
  return request({
    url: '/research/questionnaire/export',
    method: 'get',
    params: query
  })
}

// 查询调研问卷问题列表
export function researchQuestionnaireQuestionList(questionnaireId) {
  return request({
    url: '/research/questionnaire/question/list/'+ questionnaireId,
    method: 'get',
  })
}

// 查询调研问卷客户列表
export function researchQuestionnaireConsumerList(query) {
  return request({
    url: '/research/questionnaire/consumer/list',
    method: 'get',
    params: query
  })
}

// 下载题库导入模板
export function importQuestionTemplate() {
  return request({
    url: '/research/questionnaire/question/importTemplate',
    method: 'get'
  })
}

// 下载客户导入模板
export function importConsumerTemplate() {
  return request({
    url: '/research/questionnaire/consumer/importTemplate',
    method: 'get'
  })
}

// 根据url地址带的用户id获取对应题目
export function getQuestionnaireByConsumerId(consumerId) {
  return request({
    url: '/research/questionnaire/consumer/questions/'+consumerId,
    method: 'get',
  })
}

// 客户提交问卷
export function consumerCommit(data) {
  return request({
    url: '/research/questionnaire/consumer/commit',
    method: 'post',
    data: data
  })
}

// 通过选项id获取选项详情
export function getChoiceByChoiceId(choiceId) {
  return request({
    url: '/research/questionnaire/question/choice/'+choiceId,
    method: 'get',
  })
}

// 通过选项id获取多选选项详情
export function getChoiceCheckByChoiceId(choiceId) {
  return request({
    url: '/research/questionnaire/question/choice/check/'+choiceId,
    method: 'get',
  })
}

// 导出动态数据测试
export function exportTest(questionnaireId) {
  return request({
    url: '/research/questionnaire/test/'+questionnaireId,
    method: 'get',
  })
}
